<div class="row-fluid" style="margin-top:40px;">

	<div class="span9">
		<h3>
			<?php echo CHtml::encode($model->title); ?> 
		</h3>
		<i><?php echo "Created by ".$model->users->username ." in ".  $model->category->name ." category - ". ViewHelper::humanTiming(strtotime($model->created)). " ago";?></i><br/>
		<?php if ($model->verified_count > 9) { ?>
			<span>Article is verified!</span>
		<?php } else {?>
			<span>Article haven't verified yet!</span>
		<?php } ?> <br/><br/>
		<?php
			
			$this->widget('widgets.like.Like', array(
				'objectId'=>$model->id,
				'actionLike'=> Yii::app()->createUrl('like/liked/liked'),
				'actionUnlike'=> Yii::app()->createUrl('like/liked/like'),
				'classUnlike'=>'icon-thumbs-up',
				'classLike'=>'icon-thumbs-down',
				
			));

		?>
		<?php
			
			$this->widget('widgets.follow.Follow', array(
				'objectId'=>$model->id,
				'actionLike'=> Yii::app()->createUrl('follow/followed/followed'),
				'actionUnlike'=> Yii::app()->createUrl('follow/followed/follow'),
				'classUnlike'=>'icon-plus',
				'classLike'=>'icon-minus',
				
			));

		?>
		<?php
		if(currentUser() && $model->user_id != currentUser()->id){
			$this->widget('widgets.flag.Flag', array(
				'objectId'=>$model->id,
				'actionLike'=> Yii::app()->createUrl('flag/flaged/flaged'),
				'actionUnlike'=> Yii::app()->createUrl('flag/flaged/flag'),
				'classUnlike'=>'icon-envelope',
				'classLike'=>'icon-flag',
				
			));
		}
		?>
		<?php
		if(currentUser() && $model->user_id != currentUser()->id){
			$this->widget('widgets.verified.Verified', array(
				'objectId'=>$model->id,
				'actionVerified'=> Yii::app()->createUrl('verified/verified/verified'),
				'actionUnverified'=> Yii::app()->createUrl('verified/verified/unverified'),
				'classUnverified'=>'icon-ok',
				'classVerified'=>'icon-remove',
				
			));
		}
		?>
		<hr>
		<div class="row-fluid">
			<?php
			
			// if($model->image != null){
			?>
			<!--<div class="span12">
				<img src="<?php echo Yii::app()->baseUrl;?>/wwwroot/upload_files/articles/<?php echo $model->image;?>">
			</div>-->
			<?php
			// }
			?>
			<div class="span12">
				<?php echo $model->content ?>
			</div>
			
			<p>
			 <?php echo (!empty($model->source)) ? "Read more: <a href='{$model->source}' target='_blank'>{$model->source}</a>" : "";?>
			</p>
			
		</div>
		<hr>
		<div class="row-fluid">
			<h4 id="numberComment">
				<?php 
				
					$totalComment = Comments::model()->totalComment($model->id);
					echo ($totalComment == 1 ) ? $totalComment." comment" : $totalComment." comments";
					
				?>
			</h4>
			<hr>
			<?php
			if(currentUser()!=false){
			?>
			<div class="row-fluid">
				<div class="span2">
					<img src="http://placehold.it/100x100" title="<?php echo currentUser()->username;?>">
				</div>
				<div class="span10">
					<?php
					$strToken = md5(uniqid(32));
					?>
					<form action="<?php echo Yii::app()->createUrl('/comments/default/add');?>" method="POST" id="frm<?php echo $strToken;?>">
						<textarea class="span12" rows="5" name="content" id="contentComment" token="<?php echo $strToken;?>" object_id="<?php echo $model->id;?>"></textarea>
					</form>
				</div>
			</div>
			<?php
			}
			?>
			<div class="commentSelector">
			<?php
			
			if(!empty($comments)){
				foreach($comments as $key=>$comment){
					$this->renderPartial('//comment-item',array(
						'comment'=>$comment
					));
			
				}
			}
			?>
			</div>
			<?php
					
			$this->widget('ext.yiinfinite-scroll.YiinfiniteScroller', array(
				'contentSelector' => '.commentSelector',
				'itemSelector' => '.comment-item',
				'loadingText' => 'Loading more...',
				'customStyle'=>'overflow: hidden;  width: 135px;  font-size: 12px;  color: #777;  margin: 0 auto 10px;',
				'donetext' => ' ',
				'debug' => false,
				'pages' => $pages,
				'maxPage' => ceil($pages->itemCount/$pages->pageSize),
				'loading'=>array(
					'img'=>Yii::app()->theme->baseUrl."/img/ajax-loader.gif",
					'msgText'=>'Loading more...'
				)
			));
			?>
			
			
			
			
		</div>
	</div>
	<div class="span3">
		<?php
		$this->renderPartial('//menu');
		?>
		<div class="well">
			<ul id="yw1" class="nav nav-list">
				<li class="nav-header">Related article</li>
				<?php foreach ($otherArticles as $article){ ?>
				<li><a href="<?php echo Yii::App()->createUrl('/articles/view/'.$article->alias)?>"><?php echo $article->title?><!-- <span>(<?php echo Yii::app()->dateFormatter->format('d/M/yyyy',$article->created)?>)</span> --></a></li>
				<?php }?>
				
			</ul>
		</div>
	</div>
</div>
